#include "RtspServer.h"

RtspServer::RtspServer()
{
}

RtspServer::~RtspServer()
{
}

bool RtspServer::Start(std::string ip, uint16_t port)
{
	return TcpServer::Start(ip, port);
}
void RtspServer::Stop()
{
	TcpServer::Stop();
}
TcpConnection::Ptr RtspServer::OnConnect(socket_t sockfd)
{
	std::shared_ptr<WorkerThreadN> netTask = NetMgr::GetInstance()->m_oEventLoop.GetTaskScheduler();
	TcpConnection::Ptr ptr = std::make_shared<xop::RtspConnection>(std::shared_from_this(), (WorkerThreadN*)netTask.get(), sockfd);
	return ptr;
	//return std::make_shared<RtspConnection>(shared_from_this(), event_loop_->GetTaskScheduler().get(), sockfd);
}
/*

MediaSession::Ptr RtspServer::LookMediaSession(const std::string& suffix)
{
	//std::lock_guard<std::mutex> locker(mutex_);

	auto iter = rtsp_suffix_map_.find(suffix);
	if (iter != rtsp_suffix_map_.end()) {
		MediaSessionId id = iter->second;
		return media_sessions_[id];
	}

	return nullptr;
}

MediaSession::Ptr RtspServer::LookMediaSession(MediaSessionId session_Id)
{
	//std::lock_guard<std::mutex> locker(mutex_);

	auto iter = media_sessions_.find(session_Id);
	if (iter != media_sessions_.end()) {
		return iter->second;
	}

	return nullptr;
}
*/